<template>
  <div class="statistics-dashboard">
    <!-- 页面标题 -->
    <div class="dashboard-header">
      <div class="header-content">
        <div class="ancient-title">统计分析中心</div>
        <div class="header-subtitle">阴曹地府 · 数据洞察平台</div>
      </div>
      <div class="header-decoration">
        <div class="decoration-line"></div>
        <div class="decoration-symbol">⚊</div>
        <div class="decoration-line"></div>
      </div>
    </div>

    <!-- 核心统计指标 -->
    <div class="overview-section">
      <a-row :gutter="[24, 24]" class="overview-grid">
        <a-col :xs="24" :sm="12" :lg="6">
          <div class="overview-card">
            <div class="card-icon life-death">
              <UserOutlined />
            </div>
            <div class="card-content">
              <div class="card-title">生死数据</div>
              <div class="card-value">{{ totalSouls.toLocaleString() }}</div>
              <div class="card-label">累计生灵</div>
            </div>
          </div>
        </a-col>

        <a-col :xs="24" :sm="12" :lg="6">
          <div class="overview-card">
            <div class="card-icon karma">
              <HeartOutlined />
            </div>
            <div class="card-content">
              <div class="card-title">业力分析</div>
              <div class="card-value">{{ karmaHealthIndex }}%</div>
              <div class="card-label">健康指数</div>
            </div>
          </div>
        </a-col>

        <a-col :xs="24" :sm="12" :lg="6">
          <div class="overview-card">
            <div class="card-icon reincarnation">
              <ReloadOutlined />
            </div>
            <div class="card-content">
              <div class="card-title">轮回数据</div>
              <div class="card-value">{{ reincarnationSuccessRate }}%</div>
              <div class="card-label">成功率</div>
            </div>
          </div>
        </a-col>

        <a-col :xs="24" :sm="12" :lg="6">
          <div class="overview-card">
            <div class="card-icon trends">
              <LineChartOutlined />
            </div>
            <div class="card-content">
              <div class="card-title">数据趋势</div>
              <div class="card-value">{{ trendScore }}</div>
              <div class="card-label">总体评分</div>
            </div>
          </div>
        </a-col>
      </a-row>
    </div>

    <!-- 分析模块导航 -->
    <div class="modules-section">
      <!-- 生死数据统计模块 -->
      <div class="module-category">
        <h2 class="category-title">生死数据统计</h2>
        <p class="category-description">深度分析生死记录，洞察生命轨迹与死因分布</p>

        <a-row :gutter="[24, 24]" class="module-grid">
          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/life-death-trend" class="module-card">
              <div class="module-icon trend">
                <FundOutlined />
              </div>
              <div class="module-content">
                <h3>生死趋势分析</h3>
                <p>时间序列分析，趋势预测模型</p>
                <div class="module-stats">
                  <span class="stat-item">年度数据</span>
                  <span class="stat-item">趋势预测</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/death-cause" class="module-card">
              <div class="module-icon cause">
                <ExclamationCircleOutlined />
              </div>
              <div class="module-content">
                <h3>死因分类分析</h3>
                <p>死因统计，风险评估报告</p>
                <div class="module-stats">
                  <span class="stat-item">分类统计</span>
                  <span class="stat-item">风险预警</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/age-distribution" class="module-card">
              <div class="module-icon age">
                <UsergroupAddOutlined />
              </div>
              <div class="module-content">
                <h3>年龄分布统计</h3>
                <p>年龄结构分析，人口金字塔</p>
                <div class="module-stats">
                  <span class="stat-item">年龄分层</span>
                  <span class="stat-item">结构分析</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/regional-comparison" class="module-card">
              <div class="module-icon region">
                <GlobalOutlined />
              </div>
              <div class="module-content">
                <h3>地区对比分析</h3>
                <p>地域差异对比，热力图分析</p>
                <div class="module-stats">
                  <span class="stat-item">地区对比</span>
                  <span class="stat-item">热力分析</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>
        </a-row>
      </div>

      <!-- 业力分析报表模块 -->
      <div class="module-category">
        <h2 class="category-title">业力分析报表</h2>
        <p class="category-description">全面评估业力状况，优化道德指导体系</p>

        <a-row :gutter="[24, 24]" class="module-grid">
          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/karma-ratio" class="module-card">
              <div class="module-icon karma-ratio">
                <PieChartOutlined />
              </div>
              <div class="module-content">
                <h3>善恶比例统计</h3>
                <p>善恶行为比例，道德水平评估</p>
                <div class="module-stats">
                  <span class="stat-item">比例分析</span>
                  <span class="stat-item">道德评级</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/karma-distribution" class="module-card">
              <div class="module-icon karma-dist">
                <BarChartOutlined />
              </div>
              <div class="module-content">
                <h3>业力分布分析</h3>
                <p>业力值分布，统计学分析</p>
                <div class="module-stats">
                  <span class="stat-item">分布统计</span>
                  <span class="stat-item">数据挖掘</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/moral-trend" class="module-card">
              <div class="module-icon moral">
                <RiseOutlined />
              </div>
              <div class="module-content">
                <h3>道德水平趋势</h3>
                <p>道德水平变化，历史趋势分析</p>
                <div class="module-stats">
                  <span class="stat-item">趋势分析</span>
                  <span class="stat-item">预测模型</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/social-climate" class="module-card">
              <div class="module-icon social">
                <TeamOutlined />
              </div>
              <div class="module-content">
                <h3>社会风气分析</h3>
                <p>社会风气评估，文明程度监测</p>
                <div class="module-stats">
                  <span class="stat-item">风气评估</span>
                  <span class="stat-item">文明监测</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>
        </a-row>
      </div>

      <!-- 轮回数据分析模块 -->
      <div class="module-category">
        <h2 class="category-title">轮回数据分析</h2>
        <p class="category-description">优化轮回流程，提升转世效率与成功率</p>

        <a-row :gutter="[24, 24]" class="module-grid">
          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/reincarnation-success" class="module-card">
              <div class="module-icon success">
                <CheckCircleOutlined />
              </div>
              <div class="module-content">
                <h3>转世成功率</h3>
                <p>成功率分析，流程优化建议</p>
                <div class="module-stats">
                  <span class="stat-item">成功率监控</span>
                  <span class="stat-item">流程优化</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/six-realms" class="module-card">
              <div class="module-icon realms">
                <RadarChartOutlined />
              </div>
              <div class="module-content">
                <h3>六道分布统计</h3>
                <p>六道分布情况，转换流向分析</p>
                <div class="module-stats">
                  <span class="stat-item">分布统计</span>
                  <span class="stat-item">流向分析</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/cultivation-progress" class="module-card">
              <div class="module-icon cultivation">
                <TrophyOutlined />
              </div>
              <div class="module-content">
                <h3>修行进度报告</h3>
                <p>修行进度跟踪，成就统计分析</p>
                <div class="module-stats">
                  <span class="stat-item">进度跟踪</span>
                  <span class="stat-item">成就统计</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>

          <a-col :xs="24" :sm="12" :lg="6">
            <router-link to="/statistics/reincarnation-efficiency" class="module-card">
              <div class="module-icon efficiency">
                <DashboardOutlined />
              </div>
              <div class="module-content">
                <h3>轮回效率分析</h3>
                <p>效率评估，瓶颈识别与优化</p>
                <div class="module-stats">
                  <span class="stat-item">效率评估</span>
                  <span class="stat-item">瓶颈分析</span>
                </div>
              </div>
              <div class="module-arrow">
                <ArrowRightOutlined />
              </div>
            </router-link>
          </a-col>
        </a-row>
      </div>
    </div>

    <!-- 快速洞察区域 -->
    <div class="insights-section">
      <h2 class="section-title">快速洞察</h2>
      <a-row :gutter="[24, 24]">
        <a-col :xs="24" :lg="8">
          <a-card title="今日要闻" :bordered="false" class="insight-card">
            <div class="news-item" v-for="(news, index) in todayNews" :key="index">
              <div class="news-dot"></div>
              <div class="news-content">
                <div class="news-title">{{ news.title }}</div>
                <div class="news-time">{{ news.time }}</div>
              </div>
            </div>
          </a-card>
        </a-col>

        <a-col :xs="24" :lg="8">
          <a-card title="数据预警" :bordered="false" class="insight-card">
            <div class="warning-item" v-for="(warning, index) in dataWarnings" :key="index">
              <div class="warning-icon" :class="warning.level">
                <ExclamationCircleOutlined />
              </div>
              <div class="warning-content">
                <div class="warning-title">{{ warning.title }}</div>
                <div class="warning-desc">{{ warning.description }}</div>
              </div>
            </div>
          </a-card>
        </a-col>

        <a-col :xs="24" :lg="8">
          <a-card title="系统状态" :bordered="false" class="insight-card">
            <div class="status-item" v-for="(status, index) in systemStatus" :key="index">
              <div class="status-indicator" :class="status.status"></div>
              <div class="status-content">
                <div class="status-name">{{ status.name }}</div>
                <div class="status-value">{{ status.value }}</div>
              </div>
            </div>
          </a-card>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import {
  UserOutlined,
  HeartOutlined,
  ReloadOutlined,
  LineChartOutlined,
  FundOutlined,
  ExclamationCircleOutlined,
  UsergroupAddOutlined,
  GlobalOutlined,
  PieChartOutlined,
  BarChartOutlined,
  RiseOutlined,
  TeamOutlined,
  CheckCircleOutlined,
  RadarChartOutlined,
  TrophyOutlined,
  DashboardOutlined,
  ArrowRightOutlined
} from '@ant-design/icons-vue'

// 响应式数据
const totalSouls = ref(1234567)
const karmaHealthIndex = ref(87.3)
const reincarnationSuccessRate = ref(89.2)
const trendScore = ref(8.6)

// 今日要闻
const todayNews = ref([
  {
    title: '本月转世成功率创新高',
    time: '2小时前'
  },
  {
    title: '人道转世申请量持续增长',
    time: '4小时前'
  },
  {
    title: '业力评估系统升级完成',
    time: '6小时前'
  },
  {
    title: '地区死亡率统计数据更新',
    time: '8小时前'
  }
])

// 数据预警
const dataWarnings = ref([
  {
    title: '畜生道转世率偏高',
    description: '需要加强业力引导',
    level: 'warning'
  },
  {
    title: '某地区死亡率异常',
    description: '建议深入调查原因',
    level: 'error'
  },
  {
    title: '功德转换效率偏低',
    description: '系统需要优化',
    level: 'info'
  }
])

// 系统状态
const systemStatus = ref([
  {
    name: '数据库连接',
    value: '正常',
    status: 'success'
  },
  {
    name: '业力计算引擎',
    value: '运行中',
    status: 'success'
  },
  {
    name: '转世处理队列',
    value: '1,247 待处理',
    status: 'warning'
  },
  {
    name: '审核系统',
    value: '正常',
    status: 'success'
  }
])

// 组件挂载
onMounted(() => {
  console.log('统计分析中心已加载')
})
</script>

<style scoped>
.statistics-dashboard {
  min-height: 100vh;
  padding: 24px;
  color: #e6f7ff;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 48px;
  border-radius: 20px;
  position: relative;
}

.dashboard-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(64,169,255,0.3)"/><circle cx="80" cy="20" r="2" fill="rgba(82,196,26,0.3)"/><circle cx="50" cy="80" r="2" fill="rgba(114,46,209,0.3)"/></svg>');
  pointer-events: none;
}

.header-content {
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.ancient-title {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 12px;
}

.header-subtitle {
  font-size: 20px;
  color: #fff;
  opacity: 0.9;
  letter-spacing: 2px;
}

.header-decoration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.decoration-line {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d4990a, transparent);
  border-radius: 2px;
}

.decoration-symbol {
  font-size: 32px;
  color: #d4990a;
  text-shadow: 0 0 15px #d4990a;
}

.overview-section {
  margin-bottom: 48px;
}

.overview-grid .ant-col {
  margin-bottom: 24px;
}

.overview-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.overview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.overview-card:hover::before {
  transform: translateX(100%);
}

.overview-card:hover {
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(64, 169, 255, 0.5);
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
}

.card-icon.life-death {
  background: linear-gradient(45deg, #52c41a, #73d13d);
}

.card-icon.karma {
  background: linear-gradient(45deg, #1890ff, #40a9ff);
}

.card-icon.reincarnation {
  background: linear-gradient(45deg, #722ed1, #9254de);
}

.card-icon.trends {
  background: linear-gradient(45deg, #fa8c16, #ffa940);
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 16px;
  color: #91d5ff;
  margin-bottom: 8px;
  font-weight: 500;
}

.card-value {
  font-size: 36px;
  font-weight: bold;
  color: #e6f7ff;
  line-height: 1;
  margin-bottom: 6px;
}

.card-label {
  font-size: 13px;
  color: #52c41a;
  opacity: 0.8;
}

.modules-section {
  margin-bottom: 48px;
}

.module-category {
  margin-bottom: 56px;
}

.category-title {
  font-size: 32px;
  font-weight: bold;
  color: #e6f7ff;
  margin-bottom: 12px;
  background: linear-gradient(45deg, #40a9ff, #52c41a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.category-description {
  font-size: 16px;
  color: #91d5ff;
  margin-bottom: 32px;
  opacity: 0.8;
}

.module-grid .ant-col {
  margin-bottom: 24px;
}

.module-card {
  display: block;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.module-card:hover::before {
  transform: translateX(100%);
}

.module-card:hover {
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  border-color: rgba(64, 169, 255, 0.4);
  color: inherit;
  text-decoration: none;
}

.module-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: 16px;
}

.module-icon.trend {
  background: linear-gradient(45deg, #52c41a, #73d13d);
}
.module-icon.cause {
  background: linear-gradient(45deg, #ff4d4f, #ff7875);
}
.module-icon.age {
  background: linear-gradient(45deg, #1890ff, #40a9ff);
}
.module-icon.region {
  background: linear-gradient(45deg, #722ed1, #9254de);
}
.module-icon.karma-ratio {
  background: linear-gradient(45deg, #fa8c16, #ffa940);
}
.module-icon.karma-dist {
  background: linear-gradient(45deg, #13c2c2, #36cfc9);
}
.module-icon.moral {
  background: linear-gradient(45deg, #eb2f96, #f759ab);
}
.module-icon.social {
  background: linear-gradient(45deg, #52c41a, #73d13d);
}
.module-icon.success {
  background: linear-gradient(45deg, #1890ff, #40a9ff);
}
.module-icon.realms {
  background: linear-gradient(45deg, #722ed1, #9254de);
}
.module-icon.cultivation {
  background: linear-gradient(45deg, #fa8c16, #ffa940);
}
.module-icon.efficiency {
  background: linear-gradient(45deg, #f5222d, #ff4d4f);
}

.module-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: #e6f7ff;
  margin-bottom: 8px;
}

.module-content p {
  font-size: 14px;
  color: #91d5ff;
  margin-bottom: 12px;
  opacity: 0.8;
}

.module-stats {
  display: flex;
  gap: 12px;
}

.stat-item {
  font-size: 12px;
  color: #40a9ff;
  background: rgba(64, 169, 255, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(64, 169, 255, 0.2);
}

.module-arrow {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  font-size: 16px;
  color: #40a9ff;
  opacity: 0;
  transition: all 0.3s ease;
}

.module-card:hover .module-arrow {
  opacity: 1;
  transform: translateY(-50%) translateX(4px);
}

.insights-section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 28px;
  font-weight: bold;
  color: #e6f7ff;
  margin-bottom: 24px;
  background: linear-gradient(45deg, #40a9ff, #52c41a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.insight-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
}

.insight-card .ant-card-head {
  background: rgba(24, 144, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.insight-card .ant-card-head-title {
  color: #e6f7ff;
  font-weight: 600;
}

.insight-card .ant-card-body {
  background: rgba(0, 0, 0, 0.2);
}

.news-item,
.warning-item,
.status-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.news-item:last-child,
.warning-item:last-child,
.status-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.news-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #40a9ff;
  flex-shrink: 0;
}

.news-content,
.warning-content,
.status-content {
  flex: 1;
}

.news-title,
.warning-title,
.status-name {
  font-size: 14px;
  color: #e6f7ff;
  margin-bottom: 4px;
}

.news-time,
.warning-desc,
.status-value {
  font-size: 12px;
  color: #91d5ff;
  opacity: 0.7;
}

.warning-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.warning-icon.warning {
  background: #fa8c16;
  color: white;
}

.warning-icon.error {
  background: #ff4d4f;
  color: white;
}

.warning-icon.info {
  background: #1890ff;
  color: white;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.success {
  background: #52c41a;
  box-shadow: 0 0 6px rgba(82, 196, 26, 0.8);
}

.status-indicator.warning {
  background: #fa8c16;
  box-shadow: 0 0 6px rgba(250, 140, 22, 0.8);
}

.status-indicator.error {
  background: #ff4d4f;
  box-shadow: 0 0 6px rgba(255, 77, 79, 0.8);
}

@media (max-width: 768px) {
  .ancient-title {
    font-size: 36px;
  }

  .header-subtitle {
    font-size: 16px;
  }

  .category-title {
    font-size: 24px;
  }

  .card-value {
    font-size: 28px;
  }

  .module-content h3 {
    font-size: 16px;
  }
}
</style>
